Open
Conversation
New package `unstract.prompt_studio` with `PromptStudioClient` for automating Prompt Studio project promotion across environments using Platform API Key (Bearer token) authentication. Core methods: - list_projects, get_project, export_project, import_project - sync_prompts, create_profile, export_tool, upload_file - check_deployment_usage, get_default_triad High-level orchestration: - promote(): export → import/sync → optional export for deployment create_profile falls back to user's default triad when adapter IDs are not explicitly provided. Includes 15 unit tests covering all methods and promotion flows.
Greptile SummaryThis PR introduces a new Key changes:
Remaining issues:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant S as PromptStudioClient (source)
participant T as PromptStudioClient (target)
participant SA as Source API
participant TA as Target API
Note over U,TA: One-time setup (import_project + create_profile)
U->>T: import_project(export_data, adapters)
T->>TA: POST /prompt-studio/project-transfer/
TA-->>T: {tool_id, needs_adapter_config}
T-->>U: result
U->>T: create_profile(tool_id, llm, ...)
T->>TA: GET /adapter/default_triad/ (if any adapter missing)
TA-->>T: defaults
T->>TA: POST /prompt-studio/profilemanager/{tool_id}
TA-->>T: profile
Note over U,TA: Ongoing promotion via promote()
U->>S: promote(tool_id, target, target_tool_id, export=True)
S->>SA: GET /prompt-studio/project-transfer/{tool_id}
SA-->>S: export_data
S->>T: sync_prompts(target_tool_id, export_data)
T->>TA: POST /prompt-studio/{target_tool_id}/sync-prompts/
TA-->>T: {prompts_created, prompts_deleted, ...}
T-->>S: sync result
S->>T: export_tool(target_tool_id) [if export=True]
T->>TA: POST /prompt-studio/export/{target_tool_id}
TA-->>T: export_result
S-->>U: {tool_id, prompts_created, export_result}
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/unstract/prompt_studio/client.py
Line: 36
Comment:
**Unused `os` import**
`os` is imported but never referenced anywhere in this file. All file existence checks and path operations are done via `pathlib.Path`. Remove it to avoid linter warnings.
```suggestion
import logging
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/test_prompt_studio.py
Line: 244-279
Comment:
**Single mock intercepts both source and target clients**
`@patch("unstract.prompt_studio.client.requests.request")` patches the module-level `requests.request` globally, so all calls — both the `source.export_project()` call and the `target.sync_prompts()` call — route through the same `mock_request`. The test happens to work because the `side_effect` list is ordered to match call order, but the assertions don't verify *which* client made which call. If the internal call order inside `promote` ever changes (e.g., a pre-flight check is added), the `side_effect` list silently desynchronises and the test could pass while testing the wrong thing.
Consider verifying the URL of each call to make the ordering assertions explicit:
```python
export_call_url = mock_request.call_args_list[0].args[1]
assert "project-transfer" in export_call_url
sync_call_url = mock_request.call_args_list[1].args[1]
assert "sync-prompts" in sync_call_url
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: tests/test_prompt_studio.py
Line: 1-10
Comment:
**No tests for five public API methods**
The following public methods on `PromptStudioClient` have zero test coverage:
- `get_project(tool_id)`
- `check_deployment_usage(tool_id)`
- `upload_file(tool_id, file_path)`
- `get_default_triad()`
- `create_profile(tool_id, ...)`
`create_profile` in particular has non-trivial logic (conditional `get_default_triad()` fallback, missing-adapter validation, and the `is_default` flag that was recently added). A test covering at least the fully-explicit-adapters path and the fallback-to-default-triad path would help prevent regressions.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "Fix header merge ord..." |
promote() now requires target_tool_id — it only syncs into an existing project. Fresh import is a separate one-time setup step via import_project() + create_profile().
…ault - Fix file handle leaks in import_project and upload_file by reading eagerly into bytes instead of passing open file handles - Export PromptStudioClientError from package __init__ - Fix header dict mutation in _request by merging into a new dict - Expose is_default parameter in create_profile (default True) - Remove unused io import
- Let caller-supplied headers override defaults (auth as base, not top) - Raise FileNotFoundError for Path objects that don't exist instead of falling through to generic type error - Separate Path vs str-as-path handling for clarity
chandrasekharan-zipstack
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
unstract.prompt_studiopackage withPromptStudioClientfor automating Prompt Studio project promotion across environments via Platform API Key (Bearer token) auth.Methods
list_projects()get_project(tool_id)export_project(tool_id)import_project(export_data, adapters)sync_prompts(tool_id, export_data, create_copy)create_profile(tool_id, ...)export_tool(tool_id)upload_file(tool_id, file_path)check_deployment_usage(tool_id)get_default_triad()promote(tool_id, target, ...)Usage
One-time setup on target:
Ongoing promotion:
Test plan